package com.cjm.algorithm.queue;

import com.sun.org.apache.xml.internal.utils.IntStack;

class MyQueue232 {

    private IntStack in;
    private IntStack out;
    public MyQueue232() {
        in = new IntStack();
        out = new IntStack();
    }

    public void push(int x) {
        in.push(x);
    }

    public int pop() {
        if (out.empty()) {
            while (!in.empty()) {
                out.push(in.pop());
            }
        }
        return out.pop();
    }

    public int peek() {
        if (out.empty()) {
            while (!in.empty()) {
                out.push(in.pop());
            }
        }
        return out.peek();
    }

    public boolean empty() {
        return in.empty() && out.empty();
    }
}